Skip to content

BehaviorSubject.TryGetValue(T) method

Defined in

Type: BehaviorSubject Namespace: System.Reactive.Subjects Assembly: System.Reactive.dll

Applies to

netstandard2.0

public bool TryGetValue(out T value)

Summary: Tries to get the current value or throws an exception.

Parameters

NameTypeDescription
out valueTThe initial value passed to the constructor until [OnNext](# is called; after which, the last value passed to [OnNext](#

Returns: bool -- true if a value is available; false if the subject was disposed.

Remarks

The value returned from TryGetValue is frozen after OnCompleted is called.

After OnError is called, TryGetValue always throws the specified exception.

Calling TryGetValue is a thread-safe operation, though there's a potential race condition when OnNext or OnError are being invoked concurrently. In some cases, it may be necessary for a caller to use external synchronization to avoid race conditions.